home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 138 / pascal / countdig.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1987-05-13  |  402 b   |  27 lines

  1. {
  2.         Funtion CountDigits accepts a positive integer as a
  3.    parameter and returns the number of digits in the integer.
  4.  
  5. }
  6.  
  7. function
  8. CountDigits ( num : integer ): integer;
  9.  
  10.    VAR
  11.  
  12.       Digits : integer;
  13.  
  14.  
  15. BEGIN {CountDigits}
  16.  
  17. Digits := 0;
  18.  
  19. While ( num > 0 ) do begin
  20.    Digits := Digits + 1;
  21.    num := num div 10
  22. end; {While}
  23.  
  24. CountDigits := Digits
  25.  
  26. END; {CountDigits}
  27.